/** 
 路由：两种方式 1.基本路由 2.命名路由
 1.
 Navigator.of(context).push(
            MaterialPageRoute(
              builder: (context){
                return searchPage();
              }
            )
          )

 */ 
import 'package:flutter/material.dart';

import 'home.dart';
import 'menber.dart';
import 'class.dart';
import 'my.dart';
class Tabs extends StatefulWidget{
  @override
  _tabs createState()=> _tabs();
}

class _tabs extends State<Tabs>{
  int index = 0;
  List listPage = [
    homePage(),
    menberPage(),
    classPage(),
    myPage()
  ];
  var nav = [
    BottomNavigationBarItem(
      icon: Icon(Icons.home),
      title: Text("首页")
    ),
    BottomNavigationBarItem(
      icon: Icon(Icons.class_),
      title: Text("分类")
    ),
    BottomNavigationBarItem(
      icon: Icon(Icons.card_membership),
      title: Text("会员")
    ),
    BottomNavigationBarItem(
      icon: Icon(Icons.motorcycle),
      title: Text("我的")
    ),
  ];
  @override
  Widget build(BuildContext context){
    return Scaffold(
      appBar: AppBar(
        title: Text("标题"),
      ),
      body: this.listPage[this.index],
      bottomNavigationBar: BottomNavigationBar(
        items: nav,
        fixedColor: Colors.green,
        //  iconSize: 20,
        type: BottomNavigationBarType.fixed,//加上这个代码可以让灰色变成正常的颜色
        currentIndex: this.index,
        onTap: (int e){
          print(e);
          setState(() {
           this.index = e; 
          });
        },
      ),
    );
  }
}